<?php
/**
 * (exporter)
 */
namespace App\Exporter\Shipping;

use App\Models\Product\ProductClassify;
use App\Models\Shipping\SSkuLog;
use App\Util\User;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class SkuLogExporter extends ExcelExporter implements WithMapping
{

    protected $fileName = '提货记录.csv';

    protected $headings = ['品类','站点','SKU','季节性','产品名称', '需求','提货员','操作时间'];

    public function map($model) : array
    {
        return [
            $model->skuClassify->title ?? '',
            $model->area->area ?? '',
            $model->sku->psku_code ?? '',
            ProductClassify::$_season[$model->skuClassify->season ?? 3],
            $model->sku->psku_cn ?? '',
            SSkuLog::formatApply($model->apply),
            $model->seller_id ? User::getUsernameById($model->seller_id) : '',
            $model->created_at];
    }
}
